﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using Database;
using Business;
using System.Web.UI.WebControls;

namespace DT5_Anh09110006_Hung09110044_Vu09110157.QuanLy
{
    public partial class ChiTietHocVien : System.Web.UI.Page
    {
        Business.QuanLyHocVien qlhocvien = new Business.QuanLyHocVien();
        Business.QuanLyHocVien_LopHoc qlhv_lop = new Business.QuanLyHocVien_LopHoc();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Session["MaHocVien"] != null)
                {
                    loaddulieu();
                }
                else
                {
                    Response.Redirect("QuanLyHocVien.aspx");
                }
            }
          
        }
        private void loaddulieu()
        {
            String mahocvien = Session["MaHocVien"].ToString();
            HocVien hv = qlhocvien.LayHocVienTheoMa(mahocvien);
            lblMaHV.Text = hv.MaHV;
            lblbHoTenHV.Text = hv.HoTenHV;
            lblDiaChiHV.Text = hv.DiaChi;
            lblNgaySinh.Text = hv.NgaySinh.Value.ToString("MM/dd/yyyy");
            lblGioiTinh.Text = hv.GioiTinh;
            lblDienThoaiHV.Text = hv.DienThoai;
            lblCMNDHV.Text = hv.CMND;
            lblEmailHV.Text = hv.Email;
            grvLopHoc.DataSource = qlhv_lop.LayDanhSachLopHocVienTheoHoc(Session["MaHocVien"].ToString());
            grvLopHoc.DataBind();
        }
        protected void btnQuayLai_Click(object sender, EventArgs e)
        {
            Session["MaHocVien"] = null;
            Response.Redirect("QuanLyHocVien.aspx");
        }

        protected void grvQLHocVien_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            grvLopHoc.PageIndex = e.NewPageIndex;
            grvLopHoc.DataSource = qlhv_lop.LayDanhSachLopHocVienTheoHoc(Session["MaHocVien"].ToString());
            grvLopHoc.DataBind();
        }
    }
}